#组安装
sudo apt install -y tasksel
sudo tasksel

#最大化失败，设置固定分辨率
xrandr --output Virtual1 --mode 1440x900

#win10为VirtualBox安装增强功能失败
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -

echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian bionic contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list

sudo apt install -y --fix-broken virtualbox-guest-dkms
sudo apt install -y --fix-broken build-essential sudo apt sudo apt install -y  linux-headers-$(uname -r) dkms
sudo apt install -y --fix-broken virtualbox virtualbox-guest-additions-iso virtualbox-ext-pack

# sudo不输入密码
# sudo echo "super ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
#普通用户不用输入密码
sudo groupadd sudo
sudo groupadd admin
sudo usermod -G sudo super
sudo usermod -G sys super
sudo usermod -G admin super

#各种桌面
sudo apt install -y kde-minimal language-pack-kde-zh-hans-base
sudo apt install -y ubuntu-desktop lubuntu-desktop kubuntu-desktop
sudo apt install -y ubuntudde-desktop ubuntukylin-desktop ubuntustudio-desktop
sudo apt install -y ubuntu-gnome-desktop ubuntu-mate-desktop ubuntu-unity-desktop
sudo apt install -y vanilla-gnome-desktop telegram-desktop plasma-desktop

sudo apt install -y language-pack-gnome-zh-hans language-pack-zh-hans-base language-pack-zh-hans language-pack-gnome-zh-hans-base

sudo apt install -y gnome-tweak-tool gnome-shell-extensions chrome-gnome-shell

#安装cinnamon桌面
sudo add-apt-repository ppa:embrosyn/cinnamon
sudo apt update
sudo apt install -y cinnamon

#安装unity桌面
sudo apt update
sudo apt install -y ubuntu-unity-desktop

#安装deepin桌面
sudo add-apt-repository ppa:ubuntudde-dev/stable
sudo apt install -y ubuntudde-dde
sudo dpkg-reconfigure lightdm

#xfce4
sudo apt install -y xfce4

#管理软件源
cd  /etc/apt/sources.list.d/

sudo vim /etc/apt/sources.list

https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

#debian9.0 stretch
sudo apt install apt-transport-https ca-certificates
https://mirrors.tuna.tsinghua.edu.cn/help/debian/
mv /etc/apt/sources.list /etc/apt/sources.list.bak
[ -e /etc/apt/sources.list ] && touch /etc/apt/sources.list
sudo cat >> /etc/apt/sources.list <<-EOF
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security stretch/updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security stretch/updates main contrib non-free
EOF

#安装idea
sudo apt-get install snapd snapcraft
sudo snap install intellij-idea-educational --classic
#https://www.jetbrains.com/idea/download/other.html

#如果 Debian 9 环境不是中文环境需要进行切换中文环境,可以通过以下命令切换:
sudo dpkg-reconfigure locales

#kate: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory
sudo strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5

#kali
#修改 /etc/apt/sources.list , 将相关 url 改成阿里云的源。
#deb http://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free
#deb-src https://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free
#deb https://mirrors.aliyun.com/kali kali-rolling main non-free contrib
#deb-src https://mirrors.aliyun.com/kali kali-rolling main non-free contrib
#安装图形界面
apt install --fix-missing -y supervisor xfce4 xfce4-terminal
apt-get install task-xfce-desktop
#配置.bashrc
sudo cat >> ~/.bashrc <<-EOF
export DISPLAY=:0.0
export LIBGL_ALWAYS_INDIRECT=1
EOF

sudo cat >> ~/.zshrc <<-EOF
export DISPLAY=:0.0
export LIBGL_ALWAYS_INDIRECT=1
EOF

#windows命令运行
vcxsrv -ac

#启动图形界面，需配XServer使用
startxfce4

# 首先需要查看Windows系统和WSL2通信使用的虚拟网卡地址
sudo vim /etc/resolv.conf
# nameserver后面的地址就是Windows系统虚拟网卡的地址,记一下,同时需要取消下面两行内容的注释,禁用自动重新生成配置文件,否则重启后这个地址会变
[network]
generateResolvConf = false

vim ~/.bashrc
# 在文件最后追加下面内容,地址使用上面查看到的
export DISPLAY=172.17.248.225:0

#sudo apt update
#sudo apt upgrade -y

#deepin-wine
git clone https://github.com/wszqkzqk/deepin-wine-ubuntu.git
# 克隆完成之后，进入项目目录安装deepin-wine
cd deepin-wine-ubuntu
./install.sh

#自定义别名
grep "alias cls='clear'" ~/.bashrc > /dev/null
if [ $? -eq 0 ]; then
    echo "alias was seted."
else
cat >> ~/.bashrc <<-EOF
alias cls='clear'
alias apt='sudo apt --fix-missing'
alias apti='apt install -y'
alias aptr='apt remove -y'
alias apts='apt search'
alias npm='sudo npm'
alias cnpm='sudo cnpm'
alias yarn='sudo yarn'
alias pip='sudo -H pip'
alias pip3='sudo -H pip3'
alias vim='sudo vim'
alias vi='vim'
alias git='sudo git'
alias l='ls -al'
alias ll='ls -l'
alias mv='sudo mv -i'
alias cp='sudo cp -i'
alias rm='sudo rm -i'
export PAGER=most
export BROWSER=firefox
export EDITOR=vim
export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8
EOF
source ~/.bashrc
fi

#系统管理工具
sudo apt install -y unity-tweak-tool
sudo apt install -y gnome-tweak-tool
sudo apt install -y net-tools

#输入法
sudo apt install -y ibus ibus-table-wubi ibus-input-pad
sudo apt-get install ibus ibus-clutter ibus-gtk ibus-gtk3 ibus-qt4
sudo apt install -y fcitx fcitx-table-wubi
#启动ibus框架：
im-config -s ibus
sudo ibus-setup
#显示输入法图标，编辑.bashrc
cat >> ~/.bashrc <<-EOF
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
EOF
source ~/.bashrc

#常用开发工具
sudo apt install -y software-properties-common
sudo apt install -y cpp gcc g++ gdb glibc-doc autoconf
sudo apt install -y chromium-browser firefox
sudo apt install -y terminator
sudo apt install -y wget curl git tree
sudo apt install -y vim neovim vis tofrodoc
sudo apt install -y vim-scripts vim-doc vim-addon-manager
sudo apt install -y openssh-server
sudo apt install -y default-jdk
sudo apt install -y golang rustc cargo
sudo apt install -y kate kwrite
sudo apt install -y gedit gedit-dev gedit-plugins
sudo apt install -y manpages manpages-dev manpages-posix manpages-posix-dev manpages-zh most

#vscode
apt install snapd
sudo apt install apt-transport-https
sudo apt update
sudo apt install code

#nodejs相关
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash -
sudo apt-get install -y nodejs

sudo apt-get install gcc g++ make
#sudo apt-get update && sudo apt-get install yarn

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_14.x | bash -
apt-get install -y nodejs

#sudo apt install -y nodejs npm
sudo npm config set registry https://registry.npm.taobao.org
sudo npm i -g npm
sudo npm i -g cnpm --registry=https://registry.npm.taobao.org
sudo npm i -g yarn --registry=https://registry.npm.taobao.org
sudo npm i -g tldr
sudo npm i -g cheat
sudo mkdir -p ~/.config/cheat && cheat --init > ~/.config/cheat/conf.yml

#python相关
sudo apt install -y python python-pip python-setuptools ipython python3 python3-pip python3-setuptools ipython3
sudo apt install -y pyqt5-dev pyqt5-dev-tools

[ -e ~/.pip ] || sudo mkdir ~/.pip
[ -e ~/.pip/pip.conf ] || sudo touch ~/.pip/pip.conf
sudo chmod a+w ~/.pip/pip.conf
cat > ~/.pip/pip.conf <<-EOF
[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple
EOF

sudo python -m pip install --upgrade pip

sudo pip install --user ptpython --trusted-host mirrors.aliyun.com

#sudo pip install pipenv
#sudo pip install scikit-learn tensorflow --trusted-host mirrors.aliyun.com
sudo python3 -m pip install --upgrade pip
#sudo pip3 install pipenv
#sudo pip3 install scikit-learn tensorflow --trusted-host mirrors.aliyun.com
#命令行文件管理器
pip install ranger-fm --trusted-host mirrors.aliyun.com
#语法检查
pip install --user flake8 --trusted-host mirrors.aliyun.com
#自动代码提示
pip install --user jedi --trusted-host mirrors.aliyun.com
#自动导入模块
pip install --user isort --trusted-host mirrors.aliyun.com
#代码格式化
pip install --user yapf --trusted-host mirrors.aliyun.com
#通过安装 pygments扩展让vim支持 50+ 种语言（包括 go/rust/scala 等，基本覆盖所有主流语言
pip install pygments --trusted-host mirrors.aliyun.com

pip install tensorflow --trusted-host mirrors.aliyun.com

#vscode
sudo apt install -y code

#fish & oh my fish
sudo apt install -y fish
sudo git clone https://github.com/oh-my-fish/oh-my-fish
cd oh-my-fish
bin/install --offline

[ -e ~/.config/fish/config.fish ] || touch ~/.config/fish/config.fish
grep "alias cls='clear'" ~/.config/fish/config.fish > /dev/null
if [ $? -eq 0 ]; then
    echo "alias was seted."
else
cat >> ~/.config/fish/config.fish <<-EOF
alias cls='clear'
alias apt='sudo apt'
alias apti='apt install -y'
alias aptr='apt remove -y'
alias apts='apt search'
alias npm='sudo npm'
alias cnpm='sudo cnpm'
alias yarn='sudo yarn'
alias pip='sudo -H pip'
alias pip3='sudo -H pip3'
alias vim='sudo vim'
alias vi='vim'
alias git='sudo git'
alias l='ls -al'
alias ll='ls -l'
alias mv='mv -i'
alias cp='cp -i'
alias rm='rm -i'
export PAGER=most
export BROWSER=firefox
export EDITOR=vim
export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8
EOF
source ~/.config/fish/config.fish
fi

#zsh
sudo apt install -y bat zsh zsh-autosuggestions autojump zsh-syntax-highlighting
#oh my zsh
sudo apt install -y zsh
sudo git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
sudo cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
#手工安装autojump
cd ~/.oh-my-zsh/custom/plugins
git clone git://github.com/joelthelion/autojump.git
cd autojump
python3 install.py
#zsh plugins
git clone git://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/paulirish/git-open.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/git-open
#~/.zshrc
sed -i 's/plugins=(git)/plugins=(git git-open autojump zsh-autosuggestions zsh-syntax-highlighting)/g' ~/.zshrc
source ~/.zshrc

chsh -s /usr/bin/zsh

[ -e ~/.zshrc ] || sudo touch ~/.zshrc
#自定义别名
grep "alias cls='clear'" ~/.zshrc > /dev/null
if [ $? -eq 0 ]; then
    echo "alias was seted."
else
cat >> ~/.zshrc <<-EOF
alias cls='clear'
alias apt='sudo apt'
alias apti='apt install -y'
alias aptr='apt remove -y'
alias npm='sudo npm'
alias cnpm='sudo cnpm'
alias yarn='sudo yarn'
alias pip='sudo -H pip'
alias pip3='sudo -H pip3'
alias vim='sudo vim'
alias vi='vim'
alias git='sudo git'
alias l='ls -al'
alias ll='ls -l'
alias mv='mv -i'
alias cp='cp -i'
alias rm='rm -i'
export PAGER=most
export BROWSER=firefox
export EDITOR=vim
export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8
EOF
source ~/.zshrc
fi

#超好用的vim配置
#wget -qO- https://raw.github.com/ma6174/vim/master/setup.sh | sh -x

#space-vim
sudo apt install -y cscope
sudo curl -sLf https://spacevim.org/cn/install.sh | bash

#手动安装deb包
#sudo apt-get install -f
#sudo dpkg -i deb文件名

#升级所有过期库
#pip list --outdated | awk '{print "pip install --upgrade "$1}' > python-upgrade.sh
#sh python-upgrade.sh

#重新安装pip
#https://www.imooc.com/article/31953?block_id=tuijian_wz
#sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall

#atom
# sudo add-apt-repository ppa:webupd8team/atom
# sudo apt-get update
# sudo apt-get install atom

#homebrew
sudo groupadd admin
sudo usermod -G admin super
compaudit | xargs chmod g-w,o-w
sudo cp /usr/bin/chown /usr/sbin/chown
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
